import requests

cookies = {
    'YJSESSIONID': '7614C7F56C364594AF9DEEEB74586E8B',
}

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0',
    'Accept': 'application/json, text/javascript, */*; q=0.01',
    'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
    # 'Accept-Encoding': 'gzip, deflate',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'X-Requested-With': 'XMLHttpRequest',
    'Origin': 'http://59.215.208.54:91',
    'Connection': 'keep-alive',
    'Referer': 'http://59.215.208.54:91/hview/manage/evl/userevlsta.do?ismanage=1',
    # 'Cookie': 'YJSESSIONID=7614C7F56C364594AF9DEEEB74586E8B',
    'Priority': 'u=0',
}

params = {
    'ClassName': 'com.hyysoft.smart.action.pjq.Evaluation.GetUserData',
    'DB_Conn': 'SMARTPJ',
    'hall_id': '520300',
}

data = {
    'Time': '2024-07-01 ~ 2024-07-31',
    'date_query': 'Time',
    'noData': 'true',
    'page': '1',
    'rows': '100',
    'pageindex': '2',
    'ispage': '1',
    'pagesize': '100',
}

response = requests.post('http://59.215.208.54:91/sysaction.do', params=params, cookies=cookies, headers=headers, data=data)
# print(response.json()['data'])
list=[]
for i in response.json()['data']:

    姓名 =i['XName']
    部门=i['ORGNAME']
    所属区域=i['AREANAME']
    手机号=i['TEL']
    评价次数=i['Pjcount']
    非常满意=i['Dzcount']
    满意=i['Lycount']
    基本满意=i['Bmycount']
    不满意=i['Bmycount']
    非常不满意=i['Fcbmycount']
    综合评分=i['Average']
    好评率=i['PraiseProbability']
    list.append([姓名,部门,所属区域,手机号,评价次数,非常满意,满意,基本满意,不满意,非常不满意,综合评分,好评率])
import pandas as pd

# 列标题
columns = ['姓名', '部门', '所属区域', '手机号', '评价次数', '非常满意', '满意', '基本满意', '不满意', '非常不满意', '综合评分', '好评率']

# 要写入的数据
data2 = list
# 创建 DataFrame
df = pd.DataFrame(data2, columns=columns)

# 写入 Excel 文件

import pandas as pd

# 获取当前日期和时间
now = pd.Timestamp.now()

# 获取当前月份
current_month = now.month

df.to_excel(f'{data['Time']}人员评价.xlsx', index=False)
